playSound(loop=True, out=1)
oscReceive(bus=['tr1', 'tr2', 'tr3', 'tr4', 'p1', 'p2', 'p3', 'p4'],
                address=['/tr1','/tr2', '/tr3','/tr4', '/p1', '/p2', '/p3', '/p4'],
                port=8000)
recordAndLoop(1, 'tr1', nchannels=2, pitchVar='p1')
recordAndLoop(1, 'tr2', nchannels=2, pitchVar='p2')
recordAndLoop(1, 'tr3', nchannels=2, pitchVar='p3')
recordAndLoop(1, 'tr4', nchannels=2, pitchVar='p4')
startCsound()

def seq1(state):
    sendOscTrigger(1, address='/tr1')
def seq2(state):
    sendOscTrigger(1, address='/tr2')
def seq3(state):
    sendOscTrigger(1, address='/tr3')
def seq4(state):
    sendOscTrigger(1, address='/tr4')

def pit1(val):
    sendOscControl(val*0.01, address='/p1')
def pit2(val):
    sendOscControl(val*0.01, address='/p2')
def pit3(val):
    sendOscControl(val*0.01, address='/p3')
def pit4(val):
    sendOscControl(val*0.01, address='/p4')

frame = beginGUI('Sequencer', (360,400))
makeToggle(frame, 'Seq 1', (20,50), seq1)
makeSlider(frame, init=100, maxi=200, pos=(20, 100), size=(-1,250), orientation='vertical', function=pit1)
makeToggle(frame, 'Seq 2', (100,50), seq2)
makeSlider(frame, init=100, maxi=200, pos=(100, 100), size=(-1,250), orientation='vertical', function=pit2)
makeToggle(frame, 'Seq 3', (180,50), seq3)
makeSlider(frame, init=100, maxi=200, pos=(180, 100), size=(-1,250), orientation='vertical', function=pit3)
makeToggle(frame, 'Seq 4', (260,50), seq4)
makeSlider(frame, init=100, maxi=200, pos=(260, 100), size=(-1,250), orientation='vertical', function=pit4)
endGUI(frame)